package chapter2.No2_3_volatile关键字.a关键字volatile与死循环.demo1;

/**
 * Created by Administrator on 2016/11/15.
 */
public class ServiceClass {
    private boolean stop = true;

    public boolean isStop() {
        return stop;
    }

    public void setStop(boolean stop) {
        this.stop = stop;
    }

    public void methodA() {
        while(stop == true) {
            try {
                System.out.println(Thread.currentThread().getName()+" 线程执行中");
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
